package com.example.administrator.yanfoxconn.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.yanfoxconn.R;
import com.example.administrator.yanfoxconn.bean.GTMain;
import com.example.administrator.yanfoxconn.bean.LCMessage;
import com.example.administrator.yanfoxconn.bean.LMIE8S;

import java.util.List;


/**
 * IE8S 異常列表 的 適配器
 * Created by wangqian on 2018/12/22.
 */

public class LMExceListAdapter extends BaseAdapter {
    public Context mContext;
    private List<LMIE8S> lists;

    public LMExceListAdapter(Context context, List<LMIE8S> lists) {
        this.lists=lists;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int i) {
            return lists.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        int num = position +1;
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_lm_exce_item, null);

            holder.tvSite = convertView.findViewById(R.id.tv_site);
            holder.tvNum = convertView.findViewById(R.id.tv_num);
            holder.tvName = convertView.findViewById(R.id.tv_name);
            holder.tvType = convertView.findViewById(R.id.tv_type);
            holder.tvDescribe = convertView.findViewById(R.id.tv_describe);
            holder.tvDate = convertView.findViewById(R.id.tv_date);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvNum.setText(""+num);
        holder.tvName.setText(lists.get(position).getProduce_place()+"-"+lists.get(position).getBuilding()+"-"+lists.get(position).getFloor()+"-"+lists.get(position).getDepart());
       Log.e("------",lists.get(position).getProduce_place()+"-"+lists.get(position).getBuilding()+"-"+lists.get(position).getFloor()+"-"+lists.get(position).getDepart());
        holder.tvSite.setText(lists.get(position).getSite());
        holder.tvType.setText(lists.get(position).getType());
        holder.tvDescribe.setText(lists.get(position).getQuestion_describe());
        holder.tvDate.setText(lists.get(position).getCreator_time());

        return convertView;
    }

    private class ViewHolder {
        public TextView tvNum, tvName,tvSite,tvType,tvDescribe,tvDate;//編號，產品處部門，具體位置，類型，描述，日期
    }


}
